﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Com.Core.Helps;

namespace Web.Models
{
    /// <summary>
    /// 网站管理员
    /// </summary>
    [Table("WebManager")]
    [Serializable]
    public class Admin : Entity
    {
        [Key]
        public Guid Id { get; set; }

        //[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DisplayName("账号")]
        [StringLength(20)]
        public string UserName { get; set; }

        [DisplayName("真实姓名")]
        [StringLength(10)]
        public string RealName { get; set; }

        [DisplayName("密码")]
        [StringLength(100)]
        public string Password { get; set; }

        [StringLength(100)]
        public string SecurityStamp { get; set; }

        public Admin()
        {
            Id = GuidHelper.GenerateComb();
            CreateTime = DateTime.Now;
        }
    }

    /// <summary>
    /// 管理员拥有的权限
    /// </summary>
    [Serializable]
    public class AdminAuth : Entity
    {
        public Guid Id { get; set; }

        public Guid AdminId { get; set; }
        public virtual Admin Admin { get; set; }

        public int AdminNavigationAuthorizationId { get; set; }

        public virtual AdminNavigationAuthorization AdminNavigationAuthorization { get; set; }

        public AdminAuth()
        {
            Id = GuidHelper.GenerateComb();
        }
    }
}
